package cn.hacynn.nd.controller;

import cn.hacynn.nd.common.result.Result;
import cn.hacynn.nd.pojo.dto.OrderDTO;
import cn.hacynn.nd.pojo.entity.Orders;
import cn.hacynn.nd.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Hacynn
 * @Date 2024/6/5 10:42
 * @Version 1.0
 */
@RestController
@RequestMapping("/order")
@Slf4j
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
     * 添加订单
     * @param orderDTO
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody OrderDTO orderDTO) {
        log.info("添加订单:{}", orderDTO);
        Orders orders = orderService.add(orderDTO);
        return Result.success(orders);
    }

}
